package concurrent.threadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class CachedThreadPoolDemo {


    public static void main(String[] args) {
        ExecutorService executorService = Executors.newCachedThreadPool();
//        new ThreadPoolExecutor(1,Integer.MAX_VALUE,60L, TimeUnit.SECONDS,)


        for (int i = 0; i < 10; i++) {
            executorService.execute(()->{
                System.out.println("当前执行任务的线程是："+Thread.currentThread().getName());
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            });

        }

    }
}
